

function getXCheckBoxComponent() {
    //
    var vc= Vue.extend({
        name: 'x-checkbox',
        template: '<div><div v-for="(item, index) in innerOptions" :key="index" > <label>{{item.label}} </label> <input  @change="onChange"  type="checkbox"  :value="item.value"   v-model="selectedOptionsCp" ></input> </div></div>   ',
        props:['options','data','statarr','pagemode'],
        data:function() {
            return {
                titlex:'测试?',
                //selectedOptions: [],
                innerOptions:[],
                selecedStat:["0","1"]
            }
        },
        mounted:function(){
            this.innerOptions=this.$props.options;
        },
        updated:function() {
            //console.log("updated:",this.$props.pagemode,this.$refs.inputx)

            pageModeInit((this.$props.pagemode || pageMode || pagemode || 'read'),this.$el)
        },
        computed:{
            selectedOptionsCp:function(){
                var tmpSelectOptions=[];
                for(var k in this.$props.options){
                    var op=this.$props.options[k];
                    if(this.$props.data[op.value]==this.getStatConfig(true)){
                        console.log("computed > x-checkbox初始选中:",op.value)
                        tmpSelectOptions.push(op.value)
                    }
                }
                return tmpSelectOptions
                // console.log("selectedOptionsCp:",optionValue)
                // return this.$props.data[optionValue]==this.getStatConfig(true)
            }
        },
        methods:{
            getStatConfig:function(selectedBoolean){
                var index=0;
                if(selectedBoolean){
                    index=1;
                }
                console.log(this.$props.statarr)
                if(this.$props==undefined || this.$props.statarr==undefined){
                    console.log("从默认cfg获取配置:",this.selecedStat)
                    return this.selecedStat[index]
                }else{
                    console.log("从props获取配置:",this.$props.statarr)
                    return this.$props.statarr[index]
                }
            },
            onChange:function(event){
                // console.log("checkbox:",event.target.value,this.selectedOptions)
                // console.log(this.$props.options)
                this.$props.data[event.target.value]=this.getStatConfig(event.target.checked)
               
            },
            selectedOptionsCpxxxx:function(optionValue){
                console.log("??selectedOptionsCp:",optionValue)
                console.log(this.$props.data[optionValue],this.getStatConfig(true))
                console.log(this.$props.data[optionValue]==this.getStatConfig(true))
                return this.$props.data[optionValue]==this.getStatConfig(true)
            }
        }

    });

    return vc
}


Vue.component('x-checkbox', getXCheckBoxComponent());


